import java.util.List;

public class BestPromotionCalculator {
    public static PromotionOrder calculateBestPromotionAmount(List<OrderItem> orderItems) {
        PromotionResult fullReductionPromotion = new FullReductionPromotionCalculator().calculate(orderItems);
        PromotionResult discountPromotion = new DiscountPromotionCalculator().calculate(orderItems);
        PromotionResult bestPromotion = PromotionResult.getBest(fullReductionPromotion, discountPromotion);

        Double totalAmount = orderItems.stream().map(OrderItem::getAmount).reduce(Double::sum).get() - bestPromotion.getSavedAmount();

        return PromotionOrder.build(orderItems, bestPromotion, totalAmount);
    }
}
